<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register backend routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "backend" middleware group. Enjoy building your backend!
|
*/
Route::apiResource('tokens','TokenController');
Route::group(['middleware' => ['auth:backend']],function () {
    Route::apiResources([
        'data'=> 'DataController',
        'uploads' => 'UploadController',
        'me'=> 'MeController'
    ]);
});

Route::group(['middleware' => ['auth:backend','permission']],function () {

    Route::put('school-admins/{id}/refresh','SchoolAdminController@refresh')->name('school-admins.refresh');

    Route::apiResources([
        'users'=> 'UserController',
        'roles'=> 'RoleController',
        'admins'=> 'AdminController',
        'wechat-menus' => 'WechatMenuController',
        'wechat-menu-applications' => 'WechatMenuApplicationController',
        'wechat-groups' => 'WechatGroupController',
        'wechat-messages' => 'WechatMessageController',
        'wechat-medias' => 'WechatMediaController',
        'schools' => 'SchoolController',
        'school-rules' => 'SchoolRuleController',
        'school-admins'=> 'SchoolAdminController',
        'user-roles' => 'UserRoleController',
        'admin-logs' => 'AdminLogController',
        'school-admin-logs' => 'SchoolAdminLogController',
        'foods' => 'FoodController',
        'food-types' => 'FoodTypeController',
        'book-rules' => 'BookRuleController',
        'book-orders' => 'BookOrderController'
    ]);
});
